var btn=document.querySelector('button');
        var txt=document.querySelector('input');
        
        btn.onclick=function(){
            var val=txt.value;
            var xhr=new XMLHttpRequest();
            xhr.open('get','https://restapi.amap.com/v3/weather/weatherInfo?key=3f6a51edf7357fc78b56484202b2a6c4&city='+val);        
            if(val==''){
                alert('请输入城市名称');
            }
            xhr.onreadystatechange=function(){
                if(xhr.readyState==4&&xhr.status==200){
                    console.log(xhr.responseText);
                    var responseObj = JSON.parse(xhr.responseText);
                    var city = responseObj.lives[0].city;
                    console.log('城市名称：', city);
                    document.querySelector(".city").innerHTML = city;
                    var temperature = responseObj.lives[0].temperature;
                    document.querySelector(".temperature-degree").innerHTML=temperature+'°C';
                    var weather = responseObj.lives[0].weather;
                    document.querySelector(".weather-description").innerHTML=weather;
                    var humidity = responseObj.lives[0].humidity;
                    document.querySelector(".humidity").innerHTML='湿度：'+humidity+'%';
                    var windpower = responseObj.lives[0].windpower;
                    document.querySelector(".wind").innerHTML='风速：'+windpower+'km/h';
            }
        };
        xhr.send();
    };